/**
 * 生日日期转年龄
 */
(function () {
    'use strict';

    angular.module('BlurAdmin.pages')
        .filter('ageFilter', function() {
            function calculateAge(birthday) { // birthday is a date
                birthday = new Date(birthday);
                var ageDifMs = Date.now() - birthday.getTime();
                var ageDate = new Date(ageDifMs); // miliseconds from epoch
                return Math.abs(ageDate.getUTCFullYear() - 1970 + 1);
            }
            return function(birthdate) {
                return calculateAge(birthdate);
            };
        });
})();
